package poketrade.managers;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import poketrade.entities.User;

@Stateless
public class AcheterCredsManager {

	@PersistenceContext(name="Poketrade")
	EntityManager em;
	
	public User acheter(long user_buyer, float montant)
	{
		User currentUser = em.find(User.class, user_buyer);
		if (currentUser == null)
			return null;
		
		currentUser.setSolde(currentUser.getSolde() + montant);
		return currentUser;
	}
}
